package model;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import util.SimpleObject;

@XmlRootElement
public class Thuoc extends ChuDe {
	public static String DANG_VIEN = "Dạng viên";
	public static String DANG_LONG = "Dạng lỏng";
	public static String DANG_BOT = "Dạng bột";
	
	private LoaiThuoc loaiThuoc;
	private String thanhPhan;
	private String chiDinh;
	private String chongChiDinh;
	private String nhaSanXuat;
	private String quyCachDongGoi;
	private boolean thamKhaoBacSi;
	private Set<Benh> dsBenh;
	
	public Thuoc(){}

	public Thuoc(String tenChuDe, ChuDe chuDeCha, LoaiThuoc loaiThuoc, String thanhPhan, String chiDinh,
			String chongChiDinh, String nhaSanXuat, String quyCachDongGoi, boolean thamKhaoBacSi) {
		super(tenChuDe, chuDeCha, chuDeCha.loai);
		this.loaiThuoc = loaiThuoc;
		this.thanhPhan = thanhPhan;
		this.chiDinh = chiDinh;
		this.chongChiDinh = chongChiDinh;
		this.nhaSanXuat = nhaSanXuat;
		this.quyCachDongGoi = quyCachDongGoi;
		this.thamKhaoBacSi = thamKhaoBacSi;
		this.dsBenh = new HashSet<Benh>();
	}
	
	public void addBenh(Benh benh){
		dsBenh.add(benh);
	}
	
	public void removeBenh(Benh benh){
		dsBenh.remove(benh);
	}

	public LoaiThuoc getLoaiThuoc() {
		return loaiThuoc;
	}
	
	public void setLoaiThuoc(LoaiThuoc loaiThuoc) {
		this.loaiThuoc = loaiThuoc;
	}

	public String getThanhPhan() {
		return thanhPhan;
	}

	public void setThanhPhan(String thanhPhan) {
		this.thanhPhan = thanhPhan;
	}

	public String getChiDinh() {
		return chiDinh;
	}

	public void setChiDinh(String chiDinh) {
		this.chiDinh = chiDinh;
	}

	public String getChongChiDinh() {
		return chongChiDinh;
	}

	public void setChongChiDinh(String chongChiDinh) {
		this.chongChiDinh = chongChiDinh;
	}

	public String getNhaSanXuat() {
		return nhaSanXuat;
	}

	public void setNhaSanXuat(String nhaSanXuat) {
		this.nhaSanXuat = nhaSanXuat;
	}

	public String getQuyCachDongGoi() {
		return quyCachDongGoi;
	}

	public void setQuyCachDongGoi(String quyCachDongGoi) {
		this.quyCachDongGoi = quyCachDongGoi;
	}

	public boolean isThamKhaoBacSi() {
		return thamKhaoBacSi;
	}

	public void setThamKhaoBacSi(boolean thamKhaoBacSi) {
		this.thamKhaoBacSi = thamKhaoBacSi;
	}

	@XmlTransient
	public Set<Benh> getDsBenh() {
		return dsBenh;
	}
	
	@XmlElement(name="benh")
	public List<SimpleObject> getDsIdBenh(){
		List<SimpleObject> result = new ArrayList<SimpleObject>();
		SimpleObject obj = null;
		for (Benh benh : dsBenh) {
			obj = new SimpleObject(benh.getIdChuDe(), benh.getTenChuDe());
			result.add(obj);
		}
		return result;
	}

	public void setDsBenh(Set<Benh> dsBenh) {
		this.dsBenh = dsBenh;
	}
	
}
